package com.tac.common.myException;

import com.tac.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice(annotations = {RestController.class})
public class GlobalException {

    @ExceptionHandler(CustomException.class)
    public Result doException(CustomException e){
        String message = e.getMessage();
        log.info("错误原因：{}",message);
        return Result.error(message);
    }
    @ExceptionHandler(Exception.class)
    public Result doException(Exception e){
        String message = e.getMessage();
        log.info("错误原因：{}",message);
        return Result.error(message);
    }
}
